package org.android.tools;

import java.util.Hashtable;

import org.ksoap2.serialization.KvmSerializable;
import org.ksoap2.serialization.PropertyInfo;
import org.ksoap2.serialization.SoapObject;

public class ProductShop implements KvmSerializable{
	public Integer idproductShop;
	public Shop shop;
	public Product product;

	public ProductShop() {}

	public ProductShop(Shop shop, Product product) {
		this.shop = shop;
		this.product = product;
	}

	public Object getProperty(int arg0) {
		// TODO Auto-generated method stub
		switch(arg0) {
		case 0:
			return idproductShop;
		case 1:
			return product;
		case 2:
			return shop;
		}
		return null;
	}

	public int getPropertyCount() {
		// TODO Auto-generated method stub
		return 3;
	}

	public void getPropertyInfo(int arg0, Hashtable arg1, PropertyInfo arg2) {
		// TODO Auto-generated method stub
		switch(arg0)
        {
        case 0:
        	arg2.type = PropertyInfo.INTEGER_CLASS;
        	arg2.name = "idproductShop";
        	break;
        case 1:
        	arg2.type = new Product().getClass();
        	arg2.name = "product";
            break;
        case 2:
            arg2.type = new Shop().getClass();
            arg2.name = "shop";
            break;
        default:break;
        }
	}

	public void setProperty(int arg0, Object arg1) {
		// TODO Auto-generated method stub
		switch(arg0)
        {
        case 0:
            idproductShop = Integer.parseInt(arg1.toString());
            break;
        case 1:
            product = (Product) arg1;
            break;
        case 2:
            shop = (Shop)arg1;
            break;
        default:
            break;
        }
	}

	public static ProductShop[] parseProductShop(SoapObject soap)
    {
        ProductShop[] productShops = new ProductShop[soap.getPropertyCount()];
        for (int i = 0; i < productShops.length; i++) {
            SoapObject pii = (SoapObject)soap.getProperty(i);
            ProductShop productShop = new ProductShop();
            productShop.idproductShop = Integer.parseInt(pii.getProperty(0).toString());
            productShop.product = Product.parseProduct(pii,1);
            productShop.shop = Shop.parseShop(pii,2);
            productShops[i] = productShop;
        }
        return productShops;
    }

}
